
import bpy

import 全局控制.Node.插座.bl_插座基类 as 插座基类
import 节点.Core.bl_UI配色 as 配色

import engine.initLIB.load_dll as engineLib
import ctypes






def f_socketVecList_Update(self, context):
	data = tuple(self.default_value)
	engineLib.flexCAPI.f_bl_插座传入数据(ctypes.c_wchar_p(self.node.id_data.name), 
										ctypes.c_wchar_p(self.node.name), 
										ctypes.c_wchar_p(self.identifier), 
										ctypes.py_object(data),
										ctypes.c_bool(bool(self.is_output))
										)
	if context :
		self.node.id_data.f_节点数据更新_更新树([self.node])


class C_Socket_Vec2_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatVectorProperty(size=2, default=(0.0, 0.0), update=f_socketVecList_Update)

	def __init__(self):
		super(C_Socket_Vec2_Array1D, self).__init__()
		self.display_shape = 'DIAMOND'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+":[vec2]")
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)



class C_Socket_Vec2_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatVectorProperty(size=2, default=(0.0, 0.0), update=f_socketVecList_Update)

	def __init__(self):
		super(C_Socket_Vec2_Array2D, self).__init__()
		self.display_shape = 'DIAMOND'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+":[vec2]")
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)






class C_Socket_Vec3_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatVectorProperty(default=(0.0, 0.0, 0.0), update=f_socketVecList_Update)

	def __init__(self):
		super(C_Socket_Vec3_Array1D, self).__init__()
		self.display_shape = 'DIAMOND'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+":[vec3]")
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		self.default_value = data
		f_socketVecList_Update(self, None)
	def f_update(self):
		f_socketVecList_Update(self, None)








class C_Socket_Vec3_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatVectorProperty(default=(0.0, 0.0, 0.0), update=f_socketVecList_Update)

	def __init__(self):
		super(C_Socket_Vec3_Array2D, self).__init__()
		self.display_shape = 'DIAMOND'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+":[vec3]")
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)






class C_Socket_Vec4_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatVectorProperty(size=4, default=(0.0, 0.0, 0.0, 0.0), update=f_socketVecList_Update)

	def __init__(self):
		super(C_Socket_Vec4_Array1D, self).__init__()
		self.display_shape = 'DIAMOND'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+":[vec4]")
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		default_value = data
		f_socketVecList_Update(self, None)
	def f_update(self):
		f_socketVecList_Update(self, None)







class C_Socket_Vec4_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatVectorProperty(size=4, default=(0.0, 0.0, 0.0, 0.0), update=f_socketVecList_Update)

	def __init__(self):
		super(C_Socket_Vec4_Array1D, self).__init__()
		self.display_shape = 'DIAMOND'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+":[vec4]")
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)











































class C_Socket_iVec2_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntVectorProperty(size=2, default=(0, 0), update=f_socketVecList_Update)
	def __init__(self):
		super(C_Socket_iVec2_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+":[ivec2]")
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)





class C_Socket_iVec2_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntVectorProperty(size=2, default=(0, 0), update=f_socketVecList_Update)
	def __init__(self):
		super(C_Socket_iVec2_Array2D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text="[[ivec2]]:"+text)
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)








class C_Socket_iVec3_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntVectorProperty(default=(0, 0, 0), update=f_socketVecList_Update)
	def __init__(self):
		super(C_Socket_iVec3_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text="[ivec3]"+text)
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)



class C_Socket_iVec3_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntVectorProperty(default=(0, 0, 0), update=f_socketVecList_Update)
	def __init__(self):
		super(C_Socket_iVec3_Array2D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text="[[ivec3]]"+text)
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)







class C_Socket_iVec4_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntVectorProperty(size=4, default=(0, 0, 0, 0), update=f_socketVecList_Update)
	def __init__(self):
		super(C_Socket_iVec4_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=+"[ivec4]:"+text)
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)





class C_Socket_iVec4_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntVectorProperty(size=4, default=(0, 0, 0, 0), update=f_socketVecList_Update)
	def __init__(self):
		super(C_Socket_Vec4i_Array2D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=+"[ivec4]:"+text)
		
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)
























class C_Socket_uVec3_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntVectorProperty(default=(0, 0, 0), update=f_socketVecList_Update)
	def __init__(self):
		super(C_Socket_uVec3_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text="[uvec3]"+text)
	def draw_color(self, context, node):
		return 配色.g_矢量插座颜色_Array
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketVecList_Update(self, None)


























class C_Socket_矩阵2X2_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_矩阵2X2_Array1D, self).__init__()
	def draw(self, context, layout, node, text):
		layout.label(text=text)
	def draw_color(self, context, node):
		return 配色.g_矩阵插座颜色
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.name))
	def f_setData(self):
		return None

class C_Socket_矩阵2X2_Array2D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_矩阵2X2_Array2D, self).__init__()
	def draw(self, context, layout, node, text):
		layout.label(text=text)
	def draw_color(self, context, node):
		return 配色.g_矩阵插座颜色
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.name))
	def f_setData(self):
		return None








class C_Socket_矩阵3X3_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_矩阵3X3_Array1D, self).__init__()
	def draw(self, context, layout, node, text):
		layout.label(text=text)
	def draw_color(self, context, node):
		return 配色.g_矩阵插座颜色
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.name))
	def f_setData(self):
		return None


class C_Socket_矩阵3X3_Array2D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_矩阵3X3_Array2D, self).__init__()
	def draw(self, context, layout, node, text):
		layout.label(text=text)
	def draw_color(self, context, node):
		return 配色.g_矩阵插座颜色
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.name))
	def f_setData(self):
		return None









class C_Socket_矩阵4X4_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_矩阵4X4_Array1D, self).__init__()
	def draw(self, context, layout, node, text):
		layout.label(text='[M4X4]'+text)
	def draw_color(self, context, node):
		return 配色.g_矩阵插座颜色
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.name))
	def f_setData(self):
		return None
		


class C_Socket_矩阵4X4_Array2D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_矩阵4X4_Array2D, self).__init__()
	def draw(self, context, layout, node, text):
		layout.label(text='[M4X4]'+text)
	def draw_color(self, context, node):
		return 配色.g_矩阵插座颜色
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.name))
	def f_setData(self):
		return None
















class C_Socket_顶点索引_Array1D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_顶点索引_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+":[ [[int32]] ]")
	def draw_color(self, context, node):
		return (0.0, 0.0, 1.0, 1.0)
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass

class C_Socket_顶点索引_Array2D(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_顶点索引_Array2D, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+":[[ [[int32]] ]]")
	def draw_color(self, context, node):
		return (0.0, 0.0, 1.0, 1.0)
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass






'''class C_Socket_粒子(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_粒子, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+":[vec3, vec3, f32]", icon='')
		
	def draw_color(self, context, node):
		return (0.0, 0.0, 1.0, 1.0)
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取粒子插座节点数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass'''















classes = (
	C_Socket_Vec2_Array1D,
	C_Socket_Vec3_Array1D,
	C_Socket_Vec4_Array1D,

	C_Socket_Vec2_Array2D,
	C_Socket_Vec3_Array2D,
	C_Socket_Vec4_Array2D,


	C_Socket_iVec2_Array1D,
	C_Socket_iVec3_Array1D,
	C_Socket_iVec4_Array1D,
	
	C_Socket_iVec2_Array2D,
	C_Socket_iVec3_Array2D,
	C_Socket_iVec4_Array2D,


	C_Socket_uVec3_Array1D,

	
	C_Socket_矩阵2X2_Array1D,
	C_Socket_矩阵3X3_Array1D,
	C_Socket_矩阵4X4_Array1D,
	
	C_Socket_矩阵2X2_Array2D,
	C_Socket_矩阵3X3_Array2D,
	C_Socket_矩阵4X4_Array2D,


	C_Socket_顶点索引_Array1D,
	C_Socket_顶点索引_Array2D,
	#C_Socket_粒子,

)

def register():
	for c in classes:
		bpy.utils.register_class(c)

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)
	


